include( 'shared.lua' )
include( 'cl_menu.lua' )
include( 'hud.lua' )

local function ShowDoor()
	local ent = LocalPlayer():GetEyeTrace().Entity
	if ent:IsValid() and ent:Door() and LocalPlayer():EyePos():Distance(ent:GetPos()) < 110 then
		local Ownah 
		if ent:DoorOwner():IsValid() then
			Ownah = ent:DoorOwner():Nick()
		else
			Ownah = "No owner"
		end
		draw.SimpleText("Owned by: ", "ScoreboardText", ScrW()/2, ScrH()/2-65, Color(255, 255, 255, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
		draw.SimpleText(Ownah, "ScoreboardText", ScrW()/2, ScrH()/2-50, Color(255, 255, 255, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
	end
end

function sendmessage(ply, cmd, args)
	recievedmessage = args[1]
	messageTo = args[2]
	chat.AddText("Message to "..messageTo..": ",Color(0,255,0,255), recievedmessage)
end

function recievemessage(ply, cmd, args)
	recievedmessage = args[1]
	messageFrom = args[2]
	chat.AddText("Message from "..messageFrom..": ",Color(0,255,0,255),recievedmessage)
end

hook.Add("HUDPaint", "ShowDoorLabel", ShowDoor)
concommand.Add( "recievemessage", recievemessage )
concommand.Add( "sendmessage", sendmessage )